const qiniu = require('qiniu')

const accessKey = '9SMAnqH7EENTaqVvZnFGaDRT6m9Oug7IaqmgYkVK'
const secretKey = 'oGONxiycCDRKNjnEJnHOaXm7q6NnkAb9zdxXm84J'

module.exports = (options) => {
  const { filename, fsizeLimit, deadline } = options
  const policy = {
    scope: `xishibuy:${filename}`,
    deadline
  }
  const mac = new qiniu.auth.digest.Mac(accessKey, secretKey)
  const putPolicy = new qiniu.rs.PutPolicy(policy)
  const uploadToken = putPolicy.uploadToken(mac)
  return uploadToken
}
